﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;

namespace TheBullysStore.Models.ModuloAdministracion.TipoDocumentoPago
{
    public class TipoDocumentoPagoDAO
    {
        public List<TipoDocumentoPagoBean> ListarTipoDocumentoPago(TipoDocumentoPagoBean tipoDocumentoPago)
        {
            try
            {
                List<TipoDocumentoPagoBean> listaTipoDocumentoPago = new List<TipoDocumentoPagoBean>();
                String cadenaConfiguracion = ConfigurationManager.ConnectionStrings["TheBullysStore"].ConnectionString;
                SqlConnection sqlCon = new SqlConnection(cadenaConfiguracion);
                sqlCon.Open();
                string commandString = "select * from tipo_documento_pago";
                SqlCommand sqlCmd = new SqlCommand(commandString, sqlCon);

                SqlDataReader dataReader = sqlCmd.ExecuteReader();

                while (dataReader.Read())
                {
                    TipoDocumentoPagoBean tipoDoc = new TipoDocumentoPagoBean();
                    tipoDoc.Descripcion = (string)dataReader[0];
                    tipoDoc.TipoDocumentoPago = (int)dataReader[1];
                    listaTipoDocumentoPago.Add(tipoDoc);
                }
                sqlCon.Close();
                return listaTipoDocumentoPago;
            }
            catch
            {
                return null;
            }
        }
    }
}